package com.example.teatea.dao;

import com.example.teatea.project.Member;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;

public class DeleteStaff {
    public int deleteStaff(String name){
        int result = 0;
        Connection connection = null;
        ResultSet resultSet = null;
        Properties properties = new Properties();
        PreparedStatement presta = null;
        try {
            properties.load(new FileInputStream("src\\main\\resources\\com\\example\\teatea\\sql.properties"));
            String user = properties.getProperty("user");
            String password = properties.getProperty("password");
            String Driver = properties.getProperty("Driver");
            String url = properties.getProperty("url");
            Class.forName(Driver);
            String sql = "delete from staff where sName = ?";
            connection = DriverManager.getConnection(url,user,password);
            presta = connection.prepareStatement(sql);
            presta.setString(1,name);
            result = presta.executeUpdate();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }finally {
            return result;
        }
    }
}
